<template>
  <div class="risk-compliance c-shadow">
    <h4 class="detail-base-title">操作记录</h4>
    <div class="table-wrap">
      <table class="business" v-for="item in operationRecord" :key="item.id">
        <tr>
          <th>操作类型</th>
          <td v-if="item.status==0">一般状态</td>
          <!-- 没有安全期限 -->
          <td v-if="item.status==1">重点监控</td>
          <!-- 没有安全期限 -->
          <td v-if="item.status==2">设为安全</td>
          <td v-if="item.status==3">已处理</td>
          <td v-if="item.status==4">白名单</td>
          <td v-if="item.status !== 4 && item.status !== 3 && item.status !== 2 && item.status !== 1 && item.status !== 0">暂无状态</td>
          <!-- 没有安全期限 -->
          <th>操作时间</th>
          <td>{{item.oprateTime | dateFormat}}</td>
          <th>操作人</th>
          <td>{{item.realName || '--'}}</td>
        </tr>
        <tr v-if="item.status == 2 || item.status == 4">
          <th>安全期</th>
          <td>{{item.startTime | dateFormat}} —  {{item.endTime | dateFormat}}</td>
          <th>操作原因</th>
          <td colspan="3" class="long">{{item.oprateReson || '--'}}</td>
        </tr>
        <tr v-else>
          <th>操作原因</th>
          <td colspan="5" class="long">{{item.oprateReson || '--'}}</td>
        </tr>
        <tr>
          <th>烽火值</th>
          <td v-if="item.totalRiskScore">
            {{item.totalRiskScore}}
          </td>
          <td v-else-if="item.totalRiskScore === '' || typeof item.totalRiskScore === 'undefined'">
            --
          </td>
          <td v-else>0</td>
          <th>风险类型</th>
          <td colspan="2" class="long rightbor">
            {{item.riskDescription || '--'}}
          </td>
          <td class="leftbor">
            <span class="download" @click="download(item.filePath)" v-if="item.filePath">详情下载</span>
            <span v-else>暂无资源可下载</span>
          </td>
        </tr>
      </table>
    </div>
    <j-no-data v-if="this.operationRecord.length === 0" :mode="'b'" msg="s"></j-no-data>
    <div class="clearFix paging-wrap">
      <el-pagination v-if="operationPager.total>5"
        class="fr "
        @current-change="getOperationRecord"
        :current-page.sync="operationPager.pageNum"
        :page-size="operationPager.pageSize"
        layout="prev, pager, next, jumper"
        :total="operationPager.total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { entdetail as api } from '../../api'
import { jNoData } from '../../components'
// import Axios from 'axios'
export default {
  components: {
    jNoData
  },
  data() {
    return {
      operationRecord: [],
      operationPager: {
        total: 0,
        pageSize: 5,
        pageNum: 1
      },
      downSrc: window.api_host
    }
  },
  mounted() {
    this.getOperationRecord()
  },
  methods: {
    download(item) {
      this.downSrc = window.api_host
      this.downSrc = this.downSrc + '/oprateRecord/exporExcel?fileName='+ encodeURI(encodeURI(item))
      console.log(this.downSrc)
      location.href = this.downSrc
      // console.log(this.downSrc)
    },
    // 操作记录
    getOperationRecord() {
      const params = {
        entName: this.$route.query.entname,
        realName: this.$store.state.user.userInfo.realName,
        pageNum: this.operationPager.pageNum,
        pageSize: this.operationPager.pageSize
      }
      api.getOperationRecord(params).then(ret => {
        // console.log(ret.data.list)
        this.operationRecord = ret.data.list
        // 需要返回烽火值  风险类型 详情下载对应的接口  以及预览相对应的接口
        this.operationPager.total = ret.data.total
      })
    },
    entchangePaging(index) {
      this.operationPager.pageNum = index
      this.getOperationRecord(this.operationPager)
    }
  }
}
</script>
<style lang="scss" scoped>
.risk-compliance {
  padding: 28px 40px;
  font-size: 14px;
  .download,
  .preview {
    color: #388fe1;
    cursor: pointer;
  }
  .detail-base-title {
    line-height: 30px;
    font-size: 16px;
    font-weight: bold;
    padding: 0px 0 0 12px;
    position: relative;
    background-image: linear-gradient(0deg,#1891ef,#1891ef);
    background-size: 3px 16px;
    background-position: 0 7px;
    background-repeat: no-repeat;
    border-bottom: 1px solid #eee;
  }
  .table-wrap {
    padding: 30px 20px;
    .business {
      margin-top: 30px;
    }
    .business:nth-child(1) {
      margin-top: 0px;
    }
    table {
      border-collapse: collapse;
      width: 100%;
      text-align: center;
      td,
      th {
        border: 1px solid #e2e2e2;
        line-height: 40px;
      }
      th {
        line-height: 38px;
        color: #999;
        background: #f2f1f1;
      }
      td.long {
        text-align: left;
        padding: 10px;
        line-height: 24px;
      }
      td.leftbor {
        border-left: 0;
      }
      td.rightbor {
        border-right: 0;
      }
      &.business {
        th {
          width: 232px;
        }
      }
      &.business-change {
        th,
        td {
          line-height: 16px;
          padding: 10px 18px;
          word-wrap: break-word;
          word-break: break-all;
          white-space: normal;
        }
        th:first-child {
          width: 50px;
        }
        th:nth-of-type(2) {
          width: 140px;
        }
        td {
          text-align: left;
        }
        td.text-c {
          text-align: center;
        }
      }
    }
  }
}
</style>



// WEBPACK FOOTER //
// src/view/entDetail/statusChange.vue